#include <iostream>
#include <vector>
using namespace std;

long long Merge(vector<int>& nums, int left, int mid, int right) {
    vector<int> temp(right - left + 1);
    int i = left, j = mid + 1, k = 0;
    long long count = 0;

    while (i <= mid && j <= right) {
        if (nums[i] <= nums[j]) {
            temp[k++] = nums[i++];
        }
        else {
            temp[k++] = nums[j++];
            count += (mid - i + 1); 
        }
    }

    while (i <= mid) {
        temp[k++] = nums[i++];
    }
    while (j <= right) {
        temp[k++] = nums[j++];
    }

    for (i = left, k = 0; i <= right; i++, k++) {
        nums[i] = temp[k];
    }

    return count;
}

long long MergeSort(vector<int>& nums, int left, int right) {
    long long count = 0;
    if (left < right) {
        int mid = left + (right - left) / 2;
        count += MergeSort(nums, left, mid); 
        count += MergeSort(nums, mid + 1, right); 
        count += Merge(nums, left, mid, right); 
    }
    return count;
}

long long Inversions(vector<int>& nums) {
    return MergeSort(nums, 0, nums.size() - 1);
}

int main() {
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }

    long long result = Inversions(nums);
    cout << result << endl;

}